﻿/*
Copyright © 2010 François Karman

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

See <license.txt> for the complete license of the software.
*/

using System;

namespace Ghost.Tasks.Hg.Command
{
    /// <summary>
    /// Builds a Mercurial command parameter from the value of a property
    /// tagged with the <see cref="ParameterAttribute"/>.
    /// </summary>
    /// <remarks>
    /// The implementations of this interface should be stateless.
    /// </remarks>
    internal interface IParameterBuilder
    {
        /// <summary>
        /// Tests if a property is managed by the current instance.
        /// </summary>
        /// <param name="propertyType">
        /// The type of the property.
        /// </param>
        /// <returns>
        /// <c>true</c> if the instance can work with the property.
        /// </returns>
        bool CanBuild(Type propertyType);

        /// <summary>
        /// Builds the Mercurial command parameter for a specific value.
        /// </summary>
        /// <param name="parameterPrefix">
        /// The prefix used for the parameter. If empty, the builded
        /// parameter is the default parameter.
        /// </param>
        /// <param name="propertyType">
        /// The type of the property.
        /// </param>
        /// <param name="propertyValue">
        /// The current value of the property. Can be <c>null</c>.
        /// </param>
        /// <returns>
        /// The string used to represent the current property in the
        /// Mercurial command.
        /// </returns>
        /// <exception cref="NotSupportedException">
        /// The conversion of the current value is not supported by
        /// the class.
        /// </exception>
        string Build(string parameterPrefix, Type propertyType, object propertyValue);
    }
}
